package Inheritance;

import java.util.Scanner;

import Inheritance.Subject;
import Inheritance.Student;
import Inheritance.Teacher;
import Inheritance.Test;

public class Test {
    private void menu1() {
        System.out.println("欢迎使用学生选课模拟系统！" + "\n" + "菜单：" + "\n" + "1.教师登录" + "\n" + "2.学生登录" + "\n" + "请输入1或2进行选择");
    }

    private void menu2() {
        System.out.println("欢迎使用学生选课系统" + "\n" + "菜单:" + "\n" + "1.选课操作" + "\n" + "2.退课操作" + "\n" + "请输入1或2选择操作");
    }

    private void reportError() {
        System.out.println("您的输入有误，程序已终止");
    }

    private void fengexian() {
        for (int i = 1; i <= 10; i++) {
            System.out.print("-----");
        }
        ;
        System.out.println();
    }

    public static void main(String[] args) { // 程序入口
        Test TS = new Test();
        Scanner input = new Scanner(System.in);
        Subject gaoshu = new Subject(1, "gaoshu", "jiao101", "8:00");
        Subject wuli = new Subject(2, "wuli", "jiao106", "13:00");
        Subject dianlu = new Subject(3, "dianlu", "jiao201", "14:00");
        Subject xiandai = new Subject(4, "xiandai", "jiao202", "15:00");
        Subject lisan = new Subject(5, "lisan", "jiao203", "16:00");
        Subject wulishiyan = new Subject(6, "wulishiyan", "jiao204", "17:00");
        Subject moren1[] = new Subject[6];
        Subject moren2[] = new Subject[6];
        Teacher Mrwang = new Teacher(1, "Mrwang", "男", moren1, 39);
        Student StdWang = new Student(1, "StdWang", "男", moren2);
        int x = 0;
        while (true) {
            TS.fengexian();
            if (x == 0) {
                System.out.println("欢迎使用学生选课系统" + "\n" + "还未有教师开设课程，本次默认为开课操作" + "\n" + "正在进行开课操作!");
                TS.fengexian();
                System.out.println("可开课程为:" + "\n" + Subject.Subjectname + "\n" + Subject.Subjectname + "\n"
                        + Subject.Subjectname + "\n" + Subject.Subjectname + "\n" + Subject.Subjectname + "\n"
                        + Subject.Subjectname + "以上次序依次为0~5");
                TS.fengexian();
                System.out.println("请输入所开设课程");
                int z = input.nextInt();
                Subject moren[] = { gaoshu, wuli, dianlu, xiandai, lisan, wulishiyan };
                Mrwang.openSubject(Mrwang, z, moren[z], 39);
                Subject.SubjectTeacher = "Mrwang";
                TS.fengexian();
                System.out.println("是否继续进行操作?" + "\n" + "1.继续" + "\n" + "2.结束");
                TS.fengexian();
                x = input.nextInt();
                if (x == 1) {
                    continue;
                }
                TS.fengexian();
                break;
            } else {
                TS.menu1();
                TS.fengexian();
                x = input.nextInt();
                if (x == 1) {
                    System.out.println("正在进行开课操作!");
                    TS.fengexian();
                    System.out.println("可开课程为:" + "\n" + Subject.Subjectname + "\n" + Subject.Subjectname + "\n"
                            + Subject.Subjectname + "\n" + Subject.Subjectname + "\n" + Subject.Subjectname + "\n"
                            + Subject.Subjectname + "以上次序依次为0~5");
                    TS.fengexian();
                    System.out.println("请输入所开设课程");
                    int z = input.nextInt();
                    Subject moren[] = { gaoshu, wuli, dianlu, xiandai, lisan, wulishiyan };
                    Mrwang.openSubject(Mrwang, z, moren[z], 39);
                    Subject.SubjectTeacher = "Mrwang";
                } else if (x == 2) {
                    TS.fengexian();
                    TS.menu2();
                    TS.fengexian();
                    int s = input.nextInt();
                    if (s == 1) {
                        TS.fengexian();
                        System.out.println("正在进行选课操作!");
                        TS.fengexian();
                        System.out.println("可开课程为:" + "\n" + gaoshu.Subjectname + "\n" + wuli.Subjectname + "\n"
                                + dianlu.Subjectname + "\n" + xiandai.Subjectname + "\n" + lisan.Subjectname + "\n"
                                + wulishiyan.Subjectname + "以上次序依次为0~5");
                        TS.fengexian();
                        Subject moren[] = { gaoshu, wuli, dianlu, xiandai, lisan, wulishiyan };
                        int j = input.nextInt();
                        StdWang.choiceSubject(StdWang, j, moren[j]);
                    } else if (s == 2) {
                        System.out.println("正在进行退课操作!");
                        TS.fengexian();
                        int p = input.nextInt();
                        StdWang.outSubject(StdWang, p);
                    } else {
                        TS.fengexian();
                        TS.reportError();
                        TS.fengexian();
                        break;
                    }
                    TS.fengexian();
                    System.out.println("本次选课已结束，正在打印学生选课信息");
                    System.out.println("学生姓名:" + StdWang.name + "\n" + "所选课程:" + "\n");
                    for (int i = 0; i < 6; i++) {
                        if (StdWang.Subject[i] == null) {
                            continue;
                        }
                        System.out.print(StdWang.Subject[i].number + "丨" + StdWang.Subject[i].Subjectname + "丨"
                                + StdWang.Subject[i].place + "丨" + StdWang.Subject[i].Classtime + "丨"
                                + StdWang.Subject[i].SubjectTeacher + "\n");
                    }
                    TS.fengexian();
                } else {
                    TS.fengexian();
                    TS.reportError();
                    TS.fengexian();
                    break;
                }
            }
            ;
            System.out.println("是否结束系统?" + "\n" + "1.继续" + "\n" + "2.结束");
            TS.fengexian();
            int y = input.nextInt();
            if (y == 1) {
                continue;
            } else if (y == 2)
                break;
            else {
                TS.fengexian();
                TS.reportError();
                TS.fengexian();
                break;
            }
        }
        input.close();
    }
}